//
//  MovieDetailView.m
//  UI-豆瓣项目APP
//
//  Created by liuxin on 15/25/27.
//  Copyright © 2015年 孙鹏. All rights reserved.
//

#import "MovieDetailView.h"
#import "UIImageView+WebCache.h"
@implementation MovieDetailView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        [self createSubView];
    }
    return self;
}


-(void)createSubView{
    self.detaile_Image = [[UIImageView alloc]initWithFrame:CGRectMake(25, 20, 100, 150)];
//    self.detaile_Image.backgroundColor = [UIColor redColor];
    [self addSubview:self.detaile_Image];
    [_detaile_Image release];
    
    self.detaile_type = [[UILabel alloc]initWithFrame:CGRectMake(145,120,200,20)];
//    self.detaile_type.backgroundColor  = [UIColor redColor];;
    self.detaile_type.font = [UIFont systemFontOfSize:15];
    self.detaile_type.textAlignment = NSTextAlignmentLeft;
    self.detaile_type.numberOfLines = 0;
    [self addSubview:self.detaile_type];
    [_detaile_type release];
    
    self.detaile_name = [[UILabel alloc]initWithFrame:CGRectMake(145,20,200,20)];
    self.detaile_name.font = [UIFont systemFontOfSize:15];
//    self.detaile_name.backgroundColor = [UIColor redColor];;
    self.detaile_name.text = [self.movieDICT objectForKey:@"title"];
    self.detaile_name.textAlignment = NSTextAlignmentLeft;
    self.detaile_name.numberOfLines = 0;
    [self addSubview:self.detaile_name];
    [_detaile_name release];
    
    self.detaile_date = [[UILabel alloc]initWithFrame:CGRectMake(145,55,200,20)];
    self.detaile_date.font = [UIFont systemFontOfSize:15];
    self.detaile_date.textAlignment = NSTextAlignmentLeft;
//    self.detaile_date.backgroundColor = [UIColor redColor];
    self.detaile_date.numberOfLines = 0;
    [self addSubview:self.detaile_date];
    [_detaile_date release];
    
    self.detaile_time = [[UILabel alloc]initWithFrame:CGRectMake(145,90,200,20)];
    self.detaile_time.font = [UIFont systemFontOfSize:15];
    self.detaile_time.textAlignment = NSTextAlignmentLeft;
    self.detaile_time.numberOfLines = 0;
//    self.detaile_time.backgroundColor = [UIColor redColor];
    self.detaile_time.text = [self.movieDICT objectForKey:@"runtime"];
    [self addSubview:self.detaile_time];
    [_detaile_time release];
    
    
    self.detaile_country = [[UILabel alloc]initWithFrame:CGRectMake(145,150,200,20)];
    self.detaile_country.font = [UIFont systemFontOfSize:15];
    self.detaile_country.textAlignment = NSTextAlignmentLeft;
    self.detaile_country.numberOfLines = 0;
//    self.detaile_country.backgroundColor = [UIColor redColor];
    [self addSubview:self.detaile_country];
    [_detaile_country release];
    
    
    
 
    
    self.detaile_maker = [[UILabel alloc]initWithFrame:CGRectMake(25,190,200,25)];
    self.detaile_maker.font = [UIFont boldSystemFontOfSize:20];
    self.detaile_maker.textAlignment = NSTextAlignmentLeft;
    self.detaile_maker.text = @"制作人";
    [self addSubview:self.detaile_maker];
    [_detaile_maker release];
    
    self.detaile_makers = [[UILabel alloc]initWithFrame:CGRectMake(25, 220,330,20)];
    self.detaile_makers.font = [UIFont systemFontOfSize:15];
    self.detaile_makers.textAlignment = NSTextAlignmentLeft;
    self.detaile_makers.numberOfLines = 0;
//    self.detaile_makers.backgroundColor = [UIColor orangeColor];
    [self addSubview:self.detaile_makers];
    [_detaile_makers release];
    
    self.detaile_plot = [[UILabel alloc]initWithFrame:CGRectMake(25,270,200,25)];
    self.detaile_plot.font = [UIFont boldSystemFontOfSize:20];
    self.detaile_plot.textAlignment = NSTextAlignmentLeft;
    self.detaile_plot.text = @"电影情节";
    [self addSubview:self.detaile_plot];
    [self.detaile_plot sizeToFit];
    [_detaile_plot release];
    
    self.detaile_plots = [[UILabel alloc]initWithFrame:CGRectMake(25,300,330,25)];
    self.detaile_plots.textAlignment = NSTextAlignmentLeft;
//    self.detaile_plots.backgroundColor = [UIColor redColor];
    self.detaile_plots.numberOfLines = 0;
    [self addSubview:self.detaile_plots];
    [_detaile_plots release];
}

-(void)setMovieDICT:(NSMutableDictionary *)movieDICT{
    if(_movieDICT != movieDICT){
        [_movieDICT release];
        _movieDICT = [movieDICT retain];
    }
//    NSLog(@"movieDICT%@",self.movieDICT);
    self.detaile_country.text = [self.movieDICT objectForKey:@"country"];
    self.detaile_name.text =[NSString stringWithFormat:@"评分:%@  (%@评论)",[self.movieDICT objectForKey:@"rating"],[self.movieDICT objectForKey:@"rating_count"]];
    self.detaile_date.text = [self.movieDICT objectForKey:@"release_date"];
    self.detaile_time.text = [self.movieDICT objectForKey:@"runtime"];
    self.detaile_type.text = [self.movieDICT objectForKey:@"type"];
    self.detaile_makers.text = [self.movieDICT objectForKey:@"actors"];
    [self.detaile_makers sizeToFit];

    self.detaile_plots.text = [self.movieDICT objectForKey:@"plot_simple"];
    [self.detaile_plots sizeToFit];
    
    NSURL *url = [NSURL URLWithString:[self.movieDICT objectForKey:@"poster"]];
    [self.detaile_Image sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placehold"]];
}
-(void)getValueHeight:(heightBlock)height{
    height(self.detaile_plots.frame.size.height);
//    NSLog(@"height == %f",self.detaile_plots.frame.size.height);
}
@end
